package com.yociyy.admin.biz;

import cn.hutool.core.util.StrUtil;
import com.yociyy.admin.mapper.BaseDictTypeMapper;
import com.yociyy.admin.model.entity.BaseDictType;
import com.yociyy.common.utils.EntityHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 字典类型 Biz
 * 
 * @author: YoCiyy
 * @date: 2020/5/21
 */
@Service
public class BaseDictTypeBiz {

	@Autowired
	private BaseDictTypeMapper baseDictTypeMapper;

	/**
	 * 根据字典类型ID查询信息
	 *
	 * @param id 字典类型ID
	 * @return 字典类型
	 */
	public BaseDictType selectDictTypeById(Long id) {
		return baseDictTypeMapper.selectByPrimaryKey(id);
	}

	/**
	 * 查询字典类型分页列表
	 * 
	 * @param params 条件查询
	 * @return 字典类型列表
	 */
	public List<BaseDictType> selectPage(Map<String, Object> params) {
		return baseDictTypeMapper.selectPage(params);
	}

	/**
	 * 新增字典类型
	 * 
	 * @param baseDictType 字典类型信息
	 * @return 结果
	 */
	public int insertDictType(BaseDictType baseDictType) {
		EntityHelper.assembleCrtFields(baseDictType);
		return baseDictTypeMapper.insertSelective(baseDictType);
	}

	/**
	 * 修改字典类型
	 * 
	 * @param baseDictType 字典类型信息
	 * @return 结果
	 */
	public int updateDictType(BaseDictType baseDictType) {
		EntityHelper.assembleUpdFields(baseDictType);
		return baseDictTypeMapper.updateByPrimaryKeySelective(baseDictType);
	}

	/**
	 * 删除字典类型
	 * 
	 * @param ids id串
	 * @return 结果
	 */
	public int deleteDictTypeByIds(String ids) {
		return baseDictTypeMapper.deleteDictTypeByIds(StrUtil.splitToLong(ids, ","));
	}
}
